package tool;

import java.awt.*;

/**
 * @author Team X
 * @version 1
 */

public class SplashDemo
{
	/**
	 * Draw a field in which we trow a GIF file, activate a loading bar, 
	 * run method Splashdemo which will run through a for loop till its done loading
	 * @param g
	 * @param frame
	 */
    static void renderSplashFrame(Graphics2D g, int frame) {
        final String[] comps = {"Rabbits", "Foxes", "Hunters"};
        g.setComposite(AlphaComposite.Clear);
        g.fillRect(120,140,200,40);
        g.setPaintMode();
        g.setColor(Color.BLACK);
        g.drawString("Loading "+comps[(frame/5)%3]+"...", 155, 185); //120, 150 position where to put the txt "comps"
    }
   
    /** 
     *  Make a screen with a menu bar etc, need to delete and implement it in the main
     */
    public SplashDemo() {

        final SplashScreen splash = SplashScreen.getSplashScreen();
        if (splash == null) {
            System.out.println("SplashScreen.getSplashScreen() returned null");
            return;
        }
        Graphics2D g = splash.createGraphics();
        if (g == null) {
            System.out.println("g is null");
            return;
        }
        /** 
         *  This loops the loading system
         */
        for(int i=0; i<100; i++) {
            renderSplashFrame(g, i);
            splash.update();
            try {
                Thread.sleep(90); //time it takes
            }
            catch(InterruptedException e) {
            }
        }
        splash.close();
    }
}
